<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=0.5,user-scalable=no" >
<title>儿童多动症 SNAP 测试（国际版）</title>
<link href="static/css/wx.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.css" rel="stylesheet">
</head>
	<style media="screen">
		.gettext{
			width: 110px;
			display: inline-block;
		}
		input{
			outline: none;
		}
	</style>
<body>

	<form id="securecode" class="form-examlist">


		<div class="contactinfo checkcode">
			<p class="tip-alert-info nospacing">
				我们将向您填写的手机以短信形式发送安全校验码，请填写验证：
			</p>
			<ul>
				<li><span>您的手机号码：<input class="num" type="text" name="phonenum" value="" /></span></li>
				<li class="smscode"><span>短信验证码：<input class="cap" type="text" name="securecode" value="" />
				<button type="button" class="gettext getcodeBT">获取验证码</button>
		    	</span></li>
			</ul>
		</div>
		<input type="button" id="submitbt" value="确认提交" class="bottom-securecode" />
	</form>

</body>
<script src="http://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
<script src="http://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.js"></script>
<script src="js/aui-art-template-a880d14/lib/template-web.js" charset="utf-8"></script>
<script type="text/javascript">
	$().ready(function(){
		$('.gettext').click(function(){
			gettime();
			$.ajax({
				type : "POST",
				async:false,
				url: 'http://www.familyandtree.com/getcontent.php?ac=mobile_send',
				data:{
					mobile:$('.num').val()
				},
				dataType : "json",
				success : function(data){
					if (data.error != '') {
						swal({
							button: false,
							title: data.error,
						});
						return false;
					}else {
						// window.location.href="index.php";
					}
				},
				error:function(data){
					swal({
						button: false,
						title: data.error,
					});
				}
			});
		})
		$('#submitbt').click(function(){
			$.ajax({
				type : "POST",
				async:false,
				url: 'http://www.familyandtree.com/getcontent.php?ac=submit',
				data:{
					mobile:$('.num').val(),
					captcha:$('.cap').val()
				},
				dataType : "json",
				success : function(data){
					if (data.error != '') {
						swal({
							button: false,
							title: data.error,
						});
						return false;
					}else {
						window.location.href="index.php";
					}
				},
				error:function(data){
					swal({
						button: false,
						title: data.error,
					});
				}
			});
		})
		function gettime(){
			var time = 60;
			var t = setInterval(function(){
				$('.gettext').text(time + '秒后重新获取')
				$('.gettext').attr("disabled",true)
				$('.gettext').css("color","#999")
				time--;
				if (time == '0') {
					$('.gettext').text('60秒')
					$('.gettext').attr("disabled",false)
					$('.gettext').css("color","#f60")
					clearInterval(t);
				}
			},1000);
		}
	})
</script>
</html>
